{extend name="public/father" /}

{block name="main"}
<style>
    .layui-form-pane .layui-form-text{padding: 0 10px;}
    .layui-form-pane .layui-form-label{background: none !important;padding-left: 2px;border: 0;color:#000;}
    .layui-form-pane .layui-form-text input, .layui-form-pane .layui-form-text textarea{border-radius: 3px !important;}
</style>

<div class="layui-card">
    <div class="layui-card-body">

        <blockquote class="layui-elem-quote layui-quote-nm">
            <p>使用说明</p>
        </blockquote>

        <form class="layui-form layui-form-pane" method="post" style="margin-top: 10px;">

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">短视频（分享标题）</label>
                <div class="layui-input-block">
                    <select name="alias" id="alias" lay-verify="required">
                        {foreach $dsps as $v}
                        <option value="{$v.alias}"{$v.alias == $data.alias ? ' selected' : ''}>{$v.share_title}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">入口链接（二维码对应的链接）</label>
                <div class="layui-input-block">
                    <input type="text" name="url" value="{$data.url}" id="url" placeholder="入口链接（二维码）" required lay-verify="required" autocomplete="off" class="layui-input">
                    <div style="position: absolute;right: 0px;top: 0px;">
                        <button type="button" class="layui-btn layui-btn-primary" id="zidongshengcheng"><i class="layui-icon layui-icon-link"></i>自动生成</button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-form-text upload">
                <label class="layui-form-label">二维码网址</label>
                <div class="layui-input-block">
                    <input type="text" name="img" value="{$data.img}" required lay-verify="required" placeholder="二维码网址" autocomplete="off" class="layui-input upload-input">
                    <div style="position: absolute;right: 0px;top: 0px;">
                        <img class="upload-img" src="{$data.img}" style="max-height: 36px;" onclick="showImg(this.src);"><button type="button" class="layui-btn layui-btn-primary upload-button"><i class="layui-icon layui-icon-upload"></i>上传图片</button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">访问量</label>
                <div class="layui-input-block">
                    <input type="text" name="view" value="{$data.view}" required lay-verify="number" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="启用|禁用" {$data.status == 1 ? ' checked' : ''}>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="edit">立即保存</button>
                </div>
            </div>
        </form>

    </div>
</div>

<script>
    var editId = "{$data.id|default=0}";
</script>
{/block}

{block name="js"}
<script>

    $("#zidongshengcheng").click(function () {
        var alias = $("#alias").val();

        $.get("{:url('getrukouyuming')}", {alias:alias}, function (res) {
            $("#url").val(res.msg);
        }, 'json');
    });

</script>
{/block}
